package com.king01.controller;

import com.king01.entity.Log;
import com.king01.entity.Role;
import com.king01.service.RoleService;
import com.king01.service.impl.RoleServiceImpl;
import com.king01.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author：张梓康
 * @date：Created in 2023/10/9 12:04
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService roleService;

//    查询所有角色
    @RequestMapping("/list")
    public Result roleList(Integer currentPage, Integer pageSize){
        Result result = roleService.findAllRole(currentPage, pageSize);
        return result;
    }

//    添加角色
    @RequestMapping("/add")
    public Integer addRole(@RequestBody Role role){
        Integer integer = roleService.addRole(role);
        return integer;
    }

//    删除角色
    @RequestMapping("/delete")
    public Integer deleteRole(Integer roleid){
        Integer integer = roleService.deleteRole(roleid);
        return integer;
    }

//    修改角色
    @RequestMapping("/update")
    public Integer updateRole(@RequestBody Role role){
        Integer integer = roleService.updateRole(role);
        return integer;
    }
//    查找所有角色操作日志
    @RequestMapping("/logs")
    public Result log(Integer currentPage, Integer pageSize){
        Result result = roleService.findAllLog(currentPage, pageSize);
        return result;
    }
}
    